#include "stm32f10x.h"                  // Device header
#include "Delay.h"
#include "led.h"
#include "key.h"
#include "OLED.h"
#include "CountSensor.h"
#include "Timer.h"
#include "PWM.h"
#include "Servo.h"
#include "ADC.h"
#include "Motor.h"
int main()
{
	OLED_Init();
	Motor_Init(RCC_APB2Periph_GPIOA, GPIOA, GPIO_Pin_2, GPIO_Mode_AF_PP, RCC_APB1Periph_TIM2, TIM2, TIM_CKD_DIV1, TIM_CounterMode_Up, 100 - 1, 
	720 - 1, 0, TIM_OCMode_PWM1, TIM_OCPolarity_High, 0, 2, GPIO_Pin_4 | GPIO_Pin_5);
	gpio_Init(RCC_APB2Periph_GPIOB, GPIOB, GPIO_Pin_1, GPIO_Mode_IPU);//Pin_1下拉输入接开关，按一下角度自减
	int8_t Speed = 0;
	while(1)
	{
		if(key_read_value_digital(GPIOB, GPIO_Pin_1))
		{
			Speed += 10;
		}
		if(Speed >= 110)
		{
			Speed = -100;
		}
		Motor_SetSpeed(Speed, GPIOA, GPIO_Pin_4, GPIO_Pin_5, TIM2, 2);
		OLED_ShowSignedNum(1, 1, Speed, 3);
	}
}
